package com.zghhost.codedemo.other;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

/**
 * @author guohua.zhang@zhaopin.com.cn
 * @Date 2019/5/6 19:16
 */
public class HashBean extends ParameterizedTypeImpl implements Comparable<HashBean> {
    private int x;

    public HashBean(int x){
        super(Comparable.class,new Type[]{HashBean.class},HashBean.class);
        this.x = x;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    @Override
    public int hashCode() {
        return 1;
    }

    @Override
    public String toString() {
        return String.valueOf(hashCode()+"-"+x);
    }

    @Override
    public int compareTo(HashBean o) {
        return Integer.compare(x,o.x);
    }

    public static void main(String[] args){
        HashBean b = new HashBean(1);

        System.out.println(b instanceof ParameterizedType);

        Type[] ts = b.getClass().getGenericInterfaces();

        for (Type t : ts){
            System.out.println(t+"   "+(t instanceof Comparable));
            System.out.println(t+"   "+(t instanceof ParameterizedType));
        }
    }
}
